package cn.hs.controller;

import cn.hs.entity.CourseTalk;
import cn.hs.entity.Publicity;
import cn.hs.mapper.CourseTalkMapper;
import cn.hs.service.CourseTalkService;
import cn.hs.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @ClassName CourseTalkController
 * @Description TODO
 * @Author wsh
 * @Date 2024年10月28日 11:41
 * @Version 1.0
 */
@RestController
@RequestMapping("/courseTalk")
public class CourseTalkController {
    @Autowired
    private CourseTalkService courseTalkService;
    @GetMapping("/find")
    public Result find(CourseTalk courseTalk){
        List<CourseTalk> list=courseTalkService.find(courseTalk);
        return Result.success(list);
    }
    @GetMapping("/find1")
    public Result find1(CourseTalk courseTalk){
        List<CourseTalk> list= courseTalkService.find1(courseTalk);
        return Result.success(list);
    }
    @GetMapping("/findOrderByCount")
    public Result findOrderByCount(CourseTalk courseTalk){
        List<CourseTalk> list= courseTalkService.findAllOrderByCount(courseTalk);
        return Result.success(list);
    }

    @PostMapping("/insert")
    public Result insert(@RequestBody CourseTalk courseTalk){
        courseTalk.setCreateTime(new Date());
        int add = courseTalkService.insert(courseTalk);
        if (add == 1) {
            return Result.success("添加成功");
        }
        return Result.error("添加失败");
    }
}
